package com.health.call.service.impl;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.dyvmsapi.model.v20170525.ClickToDialRequest;
import com.aliyuncs.dyvmsapi.model.v20170525.ClickToDialResponse;
import com.aliyuncs.dyvmsapi.model.v20170525.QueryCallDetailByCallIdRequest;
import com.aliyuncs.dyvmsapi.model.v20170525.QueryCallDetailByCallIdResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.health.call.service.CallService;
import com.health.call.utils.HttpUtils;


import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
@Slf4j
@Service
public class CallServiceImpl implements CallService {

    private static String APP_ID_CL = "D5cuJoFt";  //登录官网后台获取的八位appId

    private static String APP_KEY_CL = "mEYAnSQQ";  //登录官网后台获取的八位appKey

    private static String API_URL_CL = "https://api.253.com/open/bidirectionalcall/out-call";  //请求的创蓝外呼URL

    private static JsonParser jsonParser = new JsonParser();

    /**
     *
     * @param caller 呼叫方 店员
     * @param called 被叫方 会员
     *
     */
    @Override
    public JsonObject ClCallOut(String caller, String called) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("appId", APP_ID_CL);
        params.put("appKey", APP_KEY_CL);
        params.put("caller", caller);
        params.put("called", called);
        String result = HttpUtils.post(API_URL_CL, params);
        // 解析json,并返回结果
        return jsonParser.parse(result).getAsJsonObject();
    }


    /**
     * 阿里外呼
     * @param caller 呼叫方 店员
     * @param called 被叫方 会员
     *  regionid 服务地址 不变
     *  accessKeyId  ak账号 不变
     *  secret ak密码 不变
     */
    @Override
    public JsonObject ALiCallOut(String caller,String called) {


    return null;
    }
    //西沃外呼是个页面 controller里转发页面
    @Override
    public String XWCallOut() {
        return null;
    }
}
